<template>
	<view class="content">
		<view style="position: fixed;top:0;background: #fff;z-index: -2;width:100%;height:100vh;"></view>
		<div style="padding: 140rpx 0;background: #fff;text-align: center;">
			<image src="/static/saoma.png" style="width: 500rpx;height: 606rpx;"></image>
			<div style="font-weight: 500;font-size: 20px;">先核销，再加油！</div>
			<div style="color: #83878E;margin-top: 8px;">请扫描团油小程序「二维码」核销使用</div>
		</div>
		<!-- @click="goPage('/pages/writeoff/confirm')" -->
		<div style="background: #fff;padding:0 16px;" v-if="qxmanage.isWriteOff===1">
			<view class="bottombtn" @click="scan" style="width: 100%;border-radius: 22px;">
				开始核销</view>
		</div>

		<rzView :stationAuth="station.stationAuth" v-if="station.stationAuth==0||station.stationAuth==4"></rzView>
	</view>
</template>

<script>
	import {
		confirmVerificationDetails,
		getUserInfo,
	} from '@/request/api.js'
	import rzView from '@/pages/my/company/rzCard.vue'
	export default {
		components: {
			rzView
		},
		data() {
			return {
				station: {
					stationAuth: null, //0未认证 1认证中 2已认证 3认证失败 4未上传企业资质
					stationId: null,
				},
				qxmanage: {
					isAfterSales: 0, // 售后权限 1是 0否
					isManageer: 0, // 是否管理员 1是 0否
					isWriteOff: 0, // 核销权限 1是 0否
				},
			}
		},
		mounted() {
			//this.open()
		},
		onShow() {
			this.getUInfo()
		},
		methods: {

			goPage(row) {
				uni.navigateTo({
					url: row,
				})
			},
			getUInfo() {
				getUserInfo().then(res => {
					this.qxmanage.isWriteOff = res.isWriteOff
					this.qxmanage.isManageer = res.isManageer
					this.qxmanage.isAfterSales = res.isAfterSales

					this.station.stationAuth = res.stationAuth
					this.station.stationId = res.stationId
					if (res.stationAuth == 1 || res.stationAuth == 3) {
						this.goPage('/pages/my/company/detail?id=' + res.stationId)
					}
				})
			},
			scan() {
				const that = this
				uni.scanCode({
					onlyFromCamera: true, //不允许从相册选择图片
					success: function(res) {
						//console.log(res.result)
						let data = {
							verificationCode: res.result
						}
						confirmVerificationDetails(data).then(rsy => {
							that.goPage('/pages/writeoff/confirm?id=' + rsy.data.id)
						})
					},
				})
				// const ewm =
				// 	'DhApvEHHA33umb6Bot/BZxUluunPmFCGJKyVFdNouX+xjbMrijv2aFNERC3PUvz/TkYpBIpFwNSBvw9LtW+vN41o70gBOmG2yLtzvOJ0+bc='
			},


		}
	}
</script>

<style scoped>

</style>